using System;
using System.Globalization;
using System.Reflection;
using System.Reflection.Emit;

namespace ns20
{
	internal class Class168 : Class167
	{
		public static Class168 class168_0 = new Class168();

		private static DynamicMethod smethod_0(string string_0, Type type_0, Type[] type_1, Type type_2)
		{
			return (!type_2.smethod_3()) ? new DynamicMethod(string_0, type_0, type_1, type_2, skipVisibility: true) : new DynamicMethod(string_0, type_0, type_1, type_2.Module, skipVisibility: true);
		}

		public override Delegate3<T, object> ns20_002EClass167_002E_206A_206E_200E_202E_206E_200B_200B_200E_202C_206A_202A_202B_200C_206A_206C_206D_202B_200F_206E_200F_202C_200D_200D_202B_202B_206F_206D_206E_206D_206B_200B_206B_200B_200E_200D_202E_202A_206C_200F_202B_202E<T>(MethodBase methodBase_0)
		{
			DynamicMethod dynamicMethod = smethod_0(methodBase_0.ToString(), typeof(object), new Type[2]
			{
				typeof(object),
				typeof(object[])
			}, methodBase_0.DeclaringType);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			method_2(methodBase_0, iLGenerator);
			return (Delegate3<T, object>)dynamicMethod.CreateDelegate(typeof(Delegate3<T, object>));
		}

		private void method_2(MethodBase methodBase_0, ILGenerator ilgenerator_0)
		{
			ParameterInfo[] parameters = methodBase_0.GetParameters();
			Label label = ilgenerator_0.DefineLabel();
			ilgenerator_0.Emit(OpCodes.Ldarg_1);
			ilgenerator_0.Emit(OpCodes.Ldlen);
			ilgenerator_0.Emit(OpCodes.Ldc_I4, parameters.Length);
			ilgenerator_0.Emit(OpCodes.Beq, label);
			ilgenerator_0.Emit(OpCodes.Newobj, typeof(TargetParameterCountException).GetConstructor(Class195.type_0));
			ilgenerator_0.Emit(OpCodes.Throw);
			ilgenerator_0.MarkLabel(label);
			if (!methodBase_0.IsConstructor && !methodBase_0.IsStatic)
			{
				ilgenerator_0.smethod_0(methodBase_0.DeclaringType);
			}
			for (int i = 0; i < parameters.Length; i++)
			{
				ilgenerator_0.Emit(OpCodes.Ldarg_1);
				ilgenerator_0.Emit(OpCodes.Ldc_I4, i);
				ilgenerator_0.Emit(OpCodes.Ldelem_Ref);
				ilgenerator_0.smethod_2(parameters[i].ParameterType);
			}
			if (methodBase_0.IsConstructor)
			{
				ilgenerator_0.Emit(OpCodes.Newobj, (ConstructorInfo)methodBase_0);
			}
			else if (methodBase_0.IsFinal || !methodBase_0.IsVirtual)
			{
				ilgenerator_0.smethod_3((MethodInfo)methodBase_0);
			}
			Type type = (methodBase_0.IsConstructor ? methodBase_0.DeclaringType : ((MethodInfo)methodBase_0).ReturnType);
			if (type != typeof(void))
			{
				ilgenerator_0.smethod_1(type);
			}
			else
			{
				ilgenerator_0.Emit(OpCodes.Ldnull);
			}
			ilgenerator_0.smethod_4();
		}

		public override Func<T> ns20_002EClass167_002E_206E_206D_200F_202C_202B_206A_206E_200E_202B_206A_206F_206A_202E_202C_206E_202D_202A_202D_202B_206F_206C_202D_206C_206C_202A_206E_200B_206A_202A_202C_206B_200C_206A_206A_200B_206D_206A_206E_200E_206E_202E<T>(Type type_0)
		{
			DynamicMethod dynamicMethod = smethod_0("Create" + type_0.FullName, typeof(T), Class195.type_0, type_0);
			dynamicMethod.InitLocals = true;
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			method_3(type_0, iLGenerator);
			return (Func<T>)dynamicMethod.CreateDelegate(typeof(Func<T>));
		}

		private void method_3(Type type_0, ILGenerator ilgenerator_0)
		{
			if (type_0.smethod_12())
			{
				ilgenerator_0.DeclareLocal(type_0);
				ilgenerator_0.Emit(OpCodes.Ldloc_0);
				ilgenerator_0.Emit(OpCodes.Box, type_0);
			}
			else
			{
				ConstructorInfo constructor = type_0.GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Class195.type_0, null);
				if (constructor == null)
				{
					throw new ArgumentException("Could not get constructor for {0}.".smethod_0(CultureInfo.InvariantCulture, type_0));
				}
				ilgenerator_0.Emit(OpCodes.Newobj, constructor);
			}
			ilgenerator_0.smethod_4();
		}

		public override Func<T, object> ns20_002EClass167_002E_200B_200C_202E_200C_202A_206E_206E_202B_202E_206F_200F_200E_202C_200C_206D_206C_200C_206E_202D_206E_200C_202D_200E_206D_200D_206C_200F_202C_200F_206C_200B_202B_202E_200B_202D_206B_202E_206A_200D_200C_202E<T>(PropertyInfo propertyInfo_0)
		{
			DynamicMethod dynamicMethod = smethod_0("Get" + propertyInfo_0.Name, typeof(T), new Type[1] { typeof(object) }, propertyInfo_0.DeclaringType);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			method_4(propertyInfo_0, iLGenerator);
			return (Func<T, object>)dynamicMethod.CreateDelegate(typeof(Func<T, object>));
		}

		private void method_4(PropertyInfo propertyInfo_0, ILGenerator ilgenerator_0)
		{
			MethodInfo getMethod = propertyInfo_0.GetGetMethod(nonPublic: true);
			if (getMethod == null)
			{
				throw new ArgumentException("Property '{0}' does not have a getter.".smethod_0(CultureInfo.InvariantCulture, propertyInfo_0.Name));
			}
			if (!getMethod.IsStatic)
			{
				ilgenerator_0.smethod_0(propertyInfo_0.DeclaringType);
			}
			ilgenerator_0.smethod_3(getMethod);
			ilgenerator_0.smethod_1(propertyInfo_0.PropertyType);
			ilgenerator_0.smethod_4();
		}

		public override Func<T, object> ns20_002EClass167_002E_200B_200C_202E_200C_202A_206E_206E_202B_202E_206F_200F_200E_202C_200C_206D_206C_200C_206E_202D_206E_200C_202D_200E_206D_200D_206C_200F_202C_200F_206C_200B_202B_202E_200B_202D_206B_202E_206A_200D_200C_202E<T>(FieldInfo fieldInfo_0)
		{
			DynamicMethod dynamicMethod = smethod_0("Get" + fieldInfo_0.Name, typeof(T), new Type[1] { typeof(object) }, fieldInfo_0.DeclaringType);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			method_5(fieldInfo_0, iLGenerator);
			return (Func<T, object>)dynamicMethod.CreateDelegate(typeof(Func<T, object>));
		}

		private void method_5(FieldInfo fieldInfo_0, ILGenerator ilgenerator_0)
		{
			if (!fieldInfo_0.IsStatic)
			{
				ilgenerator_0.smethod_0(fieldInfo_0.DeclaringType);
			}
			ilgenerator_0.Emit(OpCodes.Ldfld, fieldInfo_0);
			ilgenerator_0.smethod_1(fieldInfo_0.FieldType);
			ilgenerator_0.smethod_4();
		}

		public override Action<T, object> ns20_002EClass167_002E_206B_202C_206B_200B_202C_202E_200C_202C_200E_206B_206D_200B_202D_206A_200F_202D_206B_206D_200E_202C_206F_200D_206D_206B_206B_200D_200C_202E_206D_202A_200D_206B_202E_200F_200F_202D_206C_200C_200D_206E_202E<T>(FieldInfo fieldInfo_0)
		{
			DynamicMethod dynamicMethod = smethod_0("Set" + fieldInfo_0.Name, null, new Type[2]
			{
				typeof(T),
				typeof(object)
			}, fieldInfo_0.DeclaringType);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			smethod_1(fieldInfo_0, iLGenerator);
			return (Action<T, object>)dynamicMethod.CreateDelegate(typeof(Action<T, object>));
		}

		internal static void smethod_1(FieldInfo fieldInfo_0, ILGenerator ilgenerator_0)
		{
			if (!fieldInfo_0.IsStatic)
			{
				ilgenerator_0.smethod_0(fieldInfo_0.DeclaringType);
			}
			ilgenerator_0.Emit(OpCodes.Ldarg_1);
			ilgenerator_0.smethod_2(fieldInfo_0.FieldType);
			ilgenerator_0.Emit(OpCodes.Stfld, fieldInfo_0);
			ilgenerator_0.smethod_4();
		}

		public override Action<T, object> ns20_002EClass167_002E_206B_202C_206B_200B_202C_202E_200C_202C_200E_206B_206D_200B_202D_206A_200F_202D_206B_206D_200E_202C_206F_200D_206D_206B_206B_200D_200C_202E_206D_202A_200D_206B_202E_200F_200F_202D_206C_200C_200D_206E_202E<T>(PropertyInfo propertyInfo_0)
		{
			DynamicMethod dynamicMethod = smethod_0("Set" + propertyInfo_0.Name, null, new Type[2]
			{
				typeof(T),
				typeof(object)
			}, propertyInfo_0.DeclaringType);
			ILGenerator iLGenerator = dynamicMethod.GetILGenerator();
			smethod_2(propertyInfo_0, iLGenerator);
			return (Action<T, object>)dynamicMethod.CreateDelegate(typeof(Action<T, object>));
		}

		internal static void smethod_2(PropertyInfo propertyInfo_0, ILGenerator ilgenerator_0)
		{
			MethodInfo setMethod = propertyInfo_0.GetSetMethod(nonPublic: true);
			if (!setMethod.IsStatic)
			{
				ilgenerator_0.smethod_0(propertyInfo_0.DeclaringType);
			}
			ilgenerator_0.Emit(OpCodes.Ldarg_1);
			ilgenerator_0.smethod_2(propertyInfo_0.PropertyType);
			ilgenerator_0.smethod_3(setMethod);
			ilgenerator_0.smethod_4();
		}
	}
}
